<?php

class Form_Login extends Zend_Form
{
	public function init()
	{
		$this->setDecorators(array('FormElements', 'Form', 'Errors'));
		$this->setMethod(Zend_Form::METHOD_POST);
		
		$element = new Zend_Form_Element_Text('login');
		$element->setRequired(true);
		$element->setLabel('Логин:');
		$element->setDecorators(array(
			'ViewHelper', 
			'Label', 
			array('HtmlTag', array('tag' => 'div', 'id' => 'form_login')),
		));
		$element->addValidator(new Zend_Validate_EmailAddress());
		$element->addValidator(new Zend_Validate_Db_RecordExists('profile', 'email'));
		$this->addElement($element);
		
		$element = new Zend_Form_Element_Password('password');
		$element->setRequired(true);
		$element->setLabel('Пароль:');
		$element->setDecorators(array(
			'ViewHelper', 
			'Label', 
			array('HtmlTag', array('tag' => 'div', 'id' => 'form_password')),
		));
		$this->addElement($element);
		
		$this->setElementFilters(array(new Zend_Filter_StringTrim()));
		
		$element = new Zend_Form_Element_Submit('submit');
		$element->setDecorators(array(
			'ViewHelper',
			array('HtmlTag', array('tag' => 'div', 'id' => 'form_submit')),
		));
		$element->setLabel('Войти');
		$element->setIgnore(true);
		$this->addElement($element);
	}
}